package com.zuoban.storage.properties;

import com.zuoban.storage.properties.other.*;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @BelongsProject: zuoban-boot
 * @BelongsPackage: com.zuoban.storage.properties
 * @Author: zxy
 * @CreateTime: 2022-10-10
 * @Description: 存储配置
 */
@Data
@ConfigurationProperties(prefix = "storage")
public class StorageProperties {

    @Data
    public static class StorageConfig {
        /**
         * 域名
         */
        private String domain;

        /**
         * 前缀
         */
        private String prefix;

        /**
         * 存储类型
         */
        private StorageType type;
    }

    /**
     * 是否开启存储
     */
    private boolean enable;

    /**
     * 通用配置
     */
    private StorageConfig config;

    /**
     * 本地配置
     */
    private LocalStorageProperties local;

    /**
     * aliyun
     */
    private AliyunStorageProperties aliyun;

    /**
     * huawei
     */
    private HuaweiStorageProperties huawei;

    /**
     * qiniu
     */
    private QiniuStorageProperties qiniu;

    /**
     * tc
     */
    private TencentStorageProperties tencent;

    /**
     * minio
     */
    private MinioStorageProperties minio;

    @Bean
    @ConfigurationProperties(prefix = "storage.local")
    public LocalStorageProperties localStorageProperties() {
        return new LocalStorageProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "storage.aliyun")
    public AliyunStorageProperties aliyunStorageProperties() {
        return new AliyunStorageProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "storage.qiniu")
    public QiniuStorageProperties qiniuStorageProperties() {
        return new QiniuStorageProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "storage.huawei")
    public HuaweiStorageProperties huaweiStorageProperties() {
        return new HuaweiStorageProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "storage.minio")
    public MinioStorageProperties minioStorageProperties() {
        return new MinioStorageProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "storage.tencent")
    public TencentStorageProperties tencentStorageProperties() {
        return new TencentStorageProperties();
    }

    public  enum StorageType {
        /**
         * 本地存储
         */
        LOCAL,

        /**
         * 阿里云
         */
        ALIYUN,

        /**
         * 腾讯云
         */
        TENCENT,

        /**
         * 七牛云
         */
        QINIU,

        /**
         * 华为云
         */
        HUAWEI,

        /**
         * MINIO
         */
        MINIO;
    }
}
